package com.boc.ewr.outsrc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.boc.ewr.bcimp.entity.Cac;
import com.boc.ewr.bcimp.entity.Pro;
import com.boc.ewr.outsrc.entity.OutsrcDailyProblem;
import com.boc.ewr.outsrc.mapper.OutsrcDailyProblemMapper;
import com.boc.ewr.outsrc.service.IOutsrcDailyProblemService;
import com.boc.ewr.risk.service.ICacRiskService;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: 外包公司日常问题清单
 * @Author: jeecg-boot
 * @Date:   2023-04-20
 * @Version: V1.0
 */
@Service
public class OutsrcDailyProblemServiceImpl extends ServiceImpl<OutsrcDailyProblemMapper, OutsrcDailyProblem> implements IOutsrcDailyProblemService {

    @Autowired
    private ICacRiskService cacRiskService;

    @Autowired
    private ISysBaseAPI sysBaseAPI;

    @Override
    public OutsrcDailyProblem getByCaNo(String caNo) {

        // 获取全部Cac
        List<Cac> cacList = cacRiskService.list(
                new LambdaQueryWrapper<Cac>()
                        .eq(Cac::getCaNo, caNo)
        );
        if(cacList == null || cacList.size() == 0){
            return null;
        }

        Cac cac = cacList.get(0);
        OutsrcDailyProblem out = new OutsrcDailyProblem();
        out.setAdminOrgNo(cac.getParentBranchNo());
        out.setAdminOrgNm(sysBaseAPI.selectAllById(cac.getParentBranchNo()).getDepartName());
        out.setObranchNo(cac.getBranchNo());
        out.setObranchNm(cac.getAccName());
        out.setCaNo(caNo);
        return out;

    }
}
